<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /><!-- 控制浏览器文件模式为IE8 -->
<title>帳號列表</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="js/artDialog/skins/default.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/elegant/om-all.css" />

<script src="js/artDialog/artDialog.js?skin=blue"></script>
<script src="js/artDialog/plugins/iframeTools.js"></script>
<script src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/operamasks-ui.min.js"></script>
<script language="javascript">
	var j = jQuery.noConflict();
	j.ajaxSetup({
		cache:false,
		async: false
	});
</script>
<script>
	(function (config) {
	    config['lock'] = true;
	    config['fixed'] = true;
	    config['okVal'] = 'Ok';
	    config['cancelVal'] = 'Cancel';	  
	})(art.dialog.defaults);
	 j.omMessageBox.waiting({
	     title:'请稍候',
	     content:'服务器正在处理您的请求，请稍候...',
	 });
	 
	 function search() {
		j("#searchKey").val("search");
		var flag=true;
		if(flag)
		{
			j.omMessageBox.waiting({
		         title:'请稍候',
		         content:'服务器正在处理您的请求，请稍候...',
		     });
			document.forms[0].submit();
		}		
	}
	function reset(){
		j("#loginName").val("");
		j("#realName").val("");
	}
	
	function deleteUser(adminId){
		j.omMessageBox.confirm({
			title:'确认删除',
			content:'删除功能后，该信息不可恢复，你确定要这样做吗？',
			onClose:function(v){
		    	if(v){
					j.ajax( {
						url : './adminUser.do?action=deleteUser&adminId=' + adminId,
						date : '',
						type : 'GET',
						dateType : 'xml',
						timeout : 100000,
						error : function(xml) {
							j.omMessageBox.alert({
						           content:'响应失败！',
						           onClose:function(v){}
						    });
						},
						success : function(xml) {
							var $message = j(xml).find("delete").children("stat").text();
							if ($message == 'have') {
								j.omMessageBox.alert({
							           content:'不能删除，原因：该用户已经被分配了角色不能被删除！',
							           onClose:function(v){}
							    });
							}else if ($message == 'ok') {
								j.omMessageBox.alert({
							           content:'删除成功！',
							           onClose:function(v){
							        	   document.location.href = './adminUser.do?action=list';
							           }
							    });
							}else{
								j.omMessageBox.alert({
							           content:'删除失败！',
							           onClose:function(v){}
							    });
								return;
							}
						}
					});
		    	}
			}
		});
	}
	function enableUser(adminId,enable){
		j.omMessageBox.confirm({
			title:'启用/停用用户',
			content:'确定要启用/停用该用户？',
			onClose:function(v){
		    	if(v){
		    		j.ajax( {
						url : './adminUser.do?action=enableUser&adminId='+adminId+'&enable='+enable,
						date : '',
						type : 'GET',
						dateType : 'xml',
						timeout : 100000,
						error : function(xml) {
							j.omMessageBox.alert({
						           content:'响应失败！',
						           onClose:function(v){}
						    });
						},
						success : function(xml) {
							var $message = j(xml).find("enable").children("stat").text();
							if($message=='ok'){
								if(enable == "1"){
									j.omMessageBox.alert({
								           content:'停用成功！',
								           onClose:function(v){
								        	   document.location.href = './adminUser.do?action=list';
								           }
								    });
								}else{
									j.omMessageBox.alert({
								           content:'启用成功！',
								           onClose:function(v){
								        	   document.location.href = './adminUser.do?action=list';
								           }
								    });
								}
								
							}else{
								if(enable == "1"){
									j.omMessageBox.alert({
								           content:'停用失败！',
								           onClose:function(v){}
								    });
								}else{
									j.omMessageBox.alert({
								           content:'启用失败！',
								           onClose:function(v){}
								    });
								}
							}
						}
					});
		    	}
			}
		});
	}
	function changePassword(adminId){
		j.omMessageBox.confirm({
			title:'确认重置',
			content:'确定要重置该用户密码？',
			onClose:function(v){
		    	if(v){
		    		j.ajax( {
						url : './adminUser.do?action=changePassword&adminId='+adminId,
						date : '',
						type : 'GET',
						dateType : 'xml',
						timeout : 100000,
						error : function(xml) {
							j.omMessageBox.alert({
						           content:'响应失败！',
						           onClose:function(v){}
						    });
						},
						success : function(xml) {
							var $message = j(xml).find("password").children("stat").text();
							if($message=='ok'){		
								j.omMessageBox.alert({
							           content:'重置成功！',
							           onClose:function(v){
							        	   document.location.href = './adminUser.do?action=list';
							           }
							    });
							}else{
								j.omMessageBox.alert({
							           content:'重置失败！',
							           onClose:function(v){}
							    });
							}
						}
					});
		    	}
			}
		});
	}
</script>
</head>
<body>

	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
	    <li>首页</li>
		<li>系统管理</li>
	    <li><a href="#" onclick="javascript:window.location.href='./adminUser.do?action=list'"> 帳號管理</a></li>
		<li>帳號列表</li>
	    </ul>
	</div>
	<div class="rightinfo">
		<form id="form1" action="./adminUser.do?action=list" method="post">
			<div class="tools">

				<ul class="toolbar">
					<li onclick="javascript:window.location.href='./adminUser.do?action=toAddUser'"><span><img src="images/t01.png" /></span>新增账号</li>
				</ul>
			</div>

			<ul class="seachform">
				<li>
					<label>登錄名：</label>
					<input name="loginName" id="loginName" value="${loginName}" type="text" class="scinput" autocomplete="off"/>
				</li>
				<li>
					<label>用戶姓名：</label>
					<input name="realName" id="realName" value="${realName}" type="text" class="scinput" autocomplete="off"/>
				</li>
				<li><label>&nbsp;</label><input type="button" onclick="javascript:search();" class="scbtn" value="查询" /></li>
			</ul>

			<table class="tablelist">
				<thead>
					<tr>
						<th>序號</th>
						<th>登陆名</th>
			            <th>真實姓名</th>
			            <th>部門</th>
			            <th>廠區</th>
			            <th>電話</th>
			            <th>分機</th>
			            <th>E-mail</th>
			            <th>狀態</th>
			            <th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:set var="i" value="${(paginationSupport.curPage-1)*(paginationSupport.countPerPage)}" /> 
				<c:forEach var="list" items="${paginationSupport.resultList}">
					<c:set var="i" value="${i+1}" />
						<tr>
							<td>${i}</td>
							<td>${list.loginName}</td>
				            <td>${list.realName}</td>
				            <td>${list.orgName}</td>
				            <td>
				            	<c:choose>
				            		<c:when test="${list.dominate=='ZZK'}">鄭州綜保區</c:when>
				            		<c:when test="${list.dominate=='ZZC'}">鄭州加工區</c:when>
				            		<c:when test="${list.dominate=='JCX'}">晉城</c:when>
				            		<c:when test="${list.dominate=='JYX'}">濟源</c:when>
				            		<c:when test="${list.dominate=='LHX'}">龍華</c:when>
				            		<c:when test="${list.dominate=='GLX'}">觀瀾</c:when>
				            		<c:when test="${list.dominate=='HBX'}">鶴壁</c:when>
				            		<c:when test="${list.dominate=='NH'}">內湖</c:when>
				            		<c:otherwise>${list.dominate}</c:otherwise>
				            	</c:choose>
				            </td>
				            <td>${list.phone}</td>
				            <td>${list.telePhone}</td>
				            <td>${list.email}</td>
				            <td><c:if test="${list.enabled=='0'}">不可用</c:if><c:if test="${list.enabled=='1'}">可用</c:if></td>  
				            <td>
				            	<a href="javascript:window.location.href='./adminUser.do?action=special&adminId=${list.userId}';"> 修改</a> 
								<%-- <a href="#" onclick="changePassword('${list.adminId}')">重置密码</a>  --%>
								<c:if test="${list.loginName!='admin'}">
								<a href="#" onclick="deleteUser('${list.userId}')"> 刪除</a>   
								<a href="#" onclick="enableUser('${list.userId}','${list.enabled}')"> <c:if test="${list.enabled=='1'}">停用</c:if><c:if test="${list.enabled=='0'}">启用</c:if></a> 
								</c:if> 
				            </td>
							<td>
								
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<div class="pagin" style="float: right; padding-right: 80px;">
				<c:import url="pagination.jsp"></c:import>
			</div>
		</form>
	</div>
	<script type="text/javascript">
		$('.tablelist tbody tr:odd').addClass('odd');
		window.onload=function()
		{
			j.omMessageBox.waiting('close');
		};
	</script>
</body>
</html>